<!doctype html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title>未成年子女信息查看</title>
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css" />
    <script src="/static/js/common/common.js" type="text/javascript"></script>
    <link href="/webjars/miniui/css/demo.css" rel="stylesheet" type="text/css" />
    <link href="/static/css/default.css" rel="stylesheet" type="text/css" />
    <style>
        .discell {
            text-align:right;
            width:20%;
        }
        .input {
            width:35%;
        }
    </style>
</head>
<body>
<div class="mini-fit">
    <div style="height:100%;width: 100%;overflow-x: auto;overflow-y: auto;">
        <form id="form1" method="post">
            <input name="id" id="id" class="mini-hidden" style="width: 100%" readonly />
            <input name="prinum" id="prinum" class="mini-hidden" style="width: 100%" readonly />
            <br />
            <table align="center">
                <tr>
                    <td class="discell"><font color="#dc143c">*</font>姓&emsp;&emsp;名:</td>
                    <td class="input">
                        <input name="name" id="name" class="mini-textbox" required="true" emptyText="请输入姓名" /><font style="color: red;display: none" id="name1">被编辑</font>
                    </td>
                    <td class="discell">性&emsp;&emsp;别:</td>
                    <td class="input">
                        <input name="sex" id="sex" class="mini-combobox"
                               textField="codeName" valueField="codeId" emptyText="请选择..."
                               url="/azbj/inmates/baseinfo/getTbsysCode?codeType=2_2&pcodeId=-1&sn=1"
                        /><font style="color: red;display: none" id="sex1">被编辑</font>
                    </td>
                </tr>
                <tr>
                    <td class="discell"><font color="#dc143c">*</font>证件类型:</td>
                    <td class="input">
                        <input name="idType" id="idType" class="mini-combobox" required="true" onvaluechanged="onIdTypeMouseOut()"
                               textField="codeName" valueField="codeId" emptyText="请选择..." onclick="change()"
                               url="/azbj/inmates/baseinfo/getTbsysCode?codeType=2_13&pcodeId=-1&sn=1" /><font style="color: red;display: none" id="idType1">被编辑</font>
                    </td>
                    <td class="discell"><font color="#dc143c" id="font">*</font>证件号码:</td>
                    <td class="input">
                        <input name="znsfId" id="znsfid" class="mini-textbox" required="true" onvaluechanged="onMouseOut()" emptyText="请先选择证件类型" /><font style="color: red;display: none" id="znsfid1">被编辑</font>
                    </td>
                </tr>
                <tr>
                    <td><input class="mini-hidden" name="num" id="num"></td>
                </tr>
                <tr>
                    <td class="discell">出生日期:</td>
                    <td class="input">
                        <input property="editor" class="mini-datepicker" id="age" name="age" allowInput="true" emptyText="请选择出生日期" ondrawdate="onDrawDate"/><font style="color: red;display: none" id="age1">被编辑</font>
                    </td>
                    <td class="discell">监护人情况:</td>
                    <td class="input">
                        <input name="jianhuren" id="jianhuren" class="mini-combobox" emptyText="请选择"
                               data="[{ id: ''+'01', name: '有监护人可以履责' },{ id: ''+'02', name: '有监护人无法履责' },{ id: ''+'03', name: '无监护人' }]"
                               textField="name" valueField="id" /><font style="color: red;display: none" id="jianhuren1">被编辑</font>
                    </td>

                </tr>
                <tr>
                    <td class="discell">失&emsp;&emsp;学:</td>
                    <td class="input">
                        <input name="shixue" id="shixue" class="mini-combobox" emptyText="请选择"
                               data="[{ id: 1, name: '是' },{ id: 2, name: '否' }]"
                               textField="name" valueField="id" /><font style="color: red;display: none" id="shixue1">被编辑</font>
                    </td>
                    <td class="discell">流浪社会:</td>
                    <td class="input">
                        <input name="liulang" id="liulang" class="mini-combobox" emptyText="请选择"
                               data="[{ id: 1, name: '是' },{ id: 2, name: '否' }]"
                               textField="name" valueField="id" /><font style="color: red;display: none" id="liulang1">被编辑</font>
                    </td>
                </tr>
                <tr>
                    <td class="discell">生活困难程度:</td>
                    <td class="input">
                        <input name="kunnan" id="kunnan" class="mini-combobox" emptyText="请选择"
                               data="[{ id: ''+'01', name: '一般困难' },{ id:  ''+'02', name: '特别困难' },{ id:  ''+'03', name: '不困难' }]"
                               textField="name" valueField="id" /><font style="color: red;display: none" id="kunnan1">被编辑</font>
                    </td>
                    <td class="discell">违法犯罪行为:</td>
                    <td colspan="3">
                        <input name="fanzui" id="fanzui" class="mini-combobox" emptyText="请选择"
                               data="[{ id: 1, name: '有' },{ id: 2, name: '无' }]"
                               textField="name" valueField="id" required="false" /><font style="color: red;display: none" id="fanzui1">被编辑</font>
                    </td>
                </tr>
                <tr>
                    <td class="discell">
                        户籍地:
                    </td>
                    <td colspan="3">
                        <input id="nativepro" name="nativepro" class="mini-combobox" required="false" emptyText="省份" style="width:180px;"
                               textfield="codeName" valueField="codeId"
                               onclick="onDeptChanged('nativepro')" onvaluechanged="onValueChanged('nativepro')" />
                        <input id="nativecity" name="nativecity" class="mini-combobox" required="false" emptyText="市" style="width: 180px"
                               textfield="codeName" valueField="codeId" onclick="onDeptChanged('nativecity')"
                               onvaluechanged="onValueChanged('nativecity')" />
                        <input id="nativecou" name="nativecou" class="mini-combobox" required="false" emptyText="县" style="width: 170px"
                               textfield="codeName" valueField="codeId" onclick="onDeptChanged('nativecou')"
                               onvaluechanged="onValueChanged('nativecou')" />
                        <input id="nativevill" name="nativevill" class="mini-combobox" required="false" emptyText="街道" style="width: 150px"
                               textfield="codeName" valueField="codeId"onclick="onDeptChanged('nativevill')" /><font style="color: red;display: none" id="nativevill1">被编辑</font>
                    </td>
                </tr>
                <tr>
                    <td class="discell"></td>
                    <td colspan="3">
                        <input class="mini-textbox" required="false" style="width: 690px" emptyText="详细地址" id="nativenum" name="nativenum" /><font style="color: red;display: none" id="nativenum1">被编辑</font>
                    </td>
                </tr>
                <tr>
                    <td class="discell">
                        居住地:
                    </td>
                    <td colspan="3" class="input">
                        <input id="placepro" name="placepro" class="mini-combobox" required="false" emptyText="省份" style="width:180px;"
                               textfield="codeName" valueField="codeId"
                               onclick="onLiveChanged('placepro')" onvaluechanged="onChanged('placepro')" />
                        <input id="placecity" name="placecity" class="mini-combobox" required="false" emptyText="市" style="width: 180px"
                               textfield="codeName" valueField="codeId" onclick="onLiveChanged('placecity')"
                               onvaluechanged="onChanged('placecity')" />
                        <input id="placecou" name="placecou" class="mini-combobox" required="false" emptyText="县" style="width: 170px"
                               textfield="codeName" valueField="codeId" onclick="onLiveChanged('placecou')"
                               onvaluechanged="onChanged('placecou')" />
                        <input id="placevill" name="placevill" class="mini-combobox" required="false" emptyText="街道" style="width: 150px"
                               textfield="codeName" valueField="codeId"onclick="onLiveChanged('placevill')" /><font style="color: red;display: none" id="placevill1">被编辑</font>
                    </td>
                </tr>
                <tr>
                    <td class="discell"></td>
                    <td colspan="3">
                        <input class="mini-textbox" style="width: 690px" emptyText="详细地址" id="placenum" required="false" name="placenum" /><font style="color: red;display: none" id="placenum1">被编辑</font>
                    </td>
                </tr>
            </table>
        </form>
        <div style="padding:2px;margin: 0 auto;text-align: center">
            <a class="mini-button" iconCls="fa-close" plain="true" style="font-size: 15px" onclick="onCancel()">关闭</a>
        </div>
    </div>
</div>
<script type="text/javascript">

    mini.parse();
    var form = new mini.Form("form1");
    var id = mini.get("id");
    var priNum = mini.get("priNum");
    var znsfid = mini.get("znsfid");
    var childrenForm = new mini.Form("form1");
    var nativepro = mini.get("nativepro");
    var nativecity = mini.get("nativecity");
    var nativecou = mini.get("nativecou");
    var nativevill = mini.get("nativevill");
    var nativenum = mini.get("nativenum");
    var placepro = mini.get("placepro");
    var placecity = mini.get("placecity");
    var placecou = mini.get("placecou");
    var placevill = mini.get("placevill");
    var placenum = mini.get("placenum");


    // 保存数据
    function saveData() {
        form.validate();
        if (form.isValid() == false) {
            return;
        }
        var data = form.getData();
        var json = mini.encode(data);
        if (!onIDCardsValidation(znsfid.getValue()) && znsfid.getValue() != "") {
            mini.alert("身份号码格式不正确");
            return;
        }
        $.ajax({
            url: "/azbj/social/noadult/save",
            data: {data: json},
            type: "post",
            success: function (success) {
                if (success.code == 1) {
                    id.setValue(success.data);
                    mini.alert("保存成功", "信息提示", function () {
                        onCancel();
                    });
                } else if (success.code == 5599) {
                    mini.alert(success.message);
                } else {
                    mini.alert("保存失败");
                }
            }
        })
    }


    //标准方法接口定义
    function SetData(data) {
        form.setEnabled(false);
        if (data.id) {
            mini.get("id").setEnabled(false);
        }
        // 根据ID去数据库中查询数据
        $.ajax({
            url: "/azbj/social/getInfo?id=" + data.id,
            type: "post",
            dataType: "json",
            success: function (zndata) {
                childrenForm.setData(zndata);
                childrenForm.setChanged(false);
                if (zndata.idType == '98') {
                    znsfid.setValue('');
                    znsfid.setEnabled(false);
                    znsfid.setEmptyText("无证件号码，不用填写");
                    $("#font").hide();
                    znsfid.required = false;
                    $("#znsfid").addClass("mini-textbox-disabled mini-textbox-readOnly");
                }
                nativepro.setData([{codeId: zndata.nativepro, codeName: zndata.nativeproName}]);
                nativecity.setData([{codeId: zndata.nativecity, codeName: zndata.nativecityName}]);
                nativecou.setData([{codeId: zndata.nativecou, codeName: zndata.nativecouName}]);
                nativevill.setData([{code: zndata.nativevill, name: zndata.nativevillName}]);
                placepro.setData([{codeId: zndata.placepro, codeName: zndata.placeproName}]);
                placecity.setData([{codeId: zndata.placecity, codeName: zndata.placecityName}]);
                placecou.setData([{codeId: zndata.placecou, codeName: zndata.placecouName}]);
                placevill.setData([{code: zndata.placevill, name: zndata.placevillName}]);
            }
        });
    }

    /**
     * 户籍地址
     * @param e
     */
    function onDeptChanged(e) {
        // placepro placecity  placecou placevill
        if ("nativepro" == e) {
            nativepro.setValue("");
            var url = "/azbj/inmates/baseinfo/region/city/view?codeId=-1";
            nativepro.setUrl(url);
            nativepro.select(0);
        }
        if ("nativecity" == e) {
            var codeId = nativepro.getValue();
            nativecity.setValue("");
            var url = "/azbj/inmates/baseinfo/region/city/view?codeId=" + codeId;
            nativecity.setUrl(url);
            nativecity.select(0);
        }

        if ("nativecou" == e) {
            var codeId = nativecity.getValue();
            nativecou.setValue("");
            var url = "/azbj/inmates/baseinfo/region/city/view?codeId=" + codeId;
            nativecou.setUrl(url);
            nativecou.select(0);
        }

        if ("nativevill" == e) {
            var parent_code = nativecou.getValue();
            nativevill.setValue("");
            var url = "/azbj/inmates/baseinfo/region/street/view?parent_code=" + parent_code;
            nativevill.setUrl(url);
            nativevill.select(0);
        }
    }

    function onValueChanged(e) {
        if ("nativepro" == e) {
            nativecity.setValue("");
            nativecou.setValue("");
            nativevill.setValue("");
        }
        if ("nativecity" == e) {
            nativecou.setValue("");
            nativevill.setValue("");
        }
        if ("nativecou" == e) {
            nativevill.setValue("");
        }
    }

    /**
     * 居住地址
     *     placepro  placecity placecou placevill placenum
     * @param e
     */
    function onLiveChanged(e) {
        if ("placepro" == e) {
            placepro.setValue("");
            var url = "/azbj/inmates/baseinfo/region/city/view?codeId=-1";
            placepro.setUrl(url);
            placepro.select(0);
        }
        if ("placecity" == e) {
            var codeId = placepro.getValue();
            placecity.setValue("");
            var url = "/azbj/inmates/baseinfo/region/city/view?codeId=" + codeId;
            placecity.setUrl(url);
            placecity.select(0);
        }

        if ("placecou" == e) {
            var codeId = placecity.getValue();
            placecou.setValue("");
            var url = "/azbj/inmates/baseinfo/region/city/view?codeId=" + codeId;
            placecou.setUrl(url);
            placecou.select(0);
        }

        if ("placevill" == e) {
            var parent_code = placecou.getValue();
            placevill.setValue("");
            var url = "/azbj/inmates/baseinfo/region/street/view?parent_code=" + parent_code;
            placevill.setUrl(url);
            placevill.select(0);
        }
    }

    function onChanged(e) {
        if ("placepro" == e) {
            placecity.setValue("");
            placecou.setValue("");
            placevill.setValue("");
        }
        if ("placecity" == e) {
            placecou.setValue("");
            placevill.setValue("");
        }
        if ("placecou" == e) {
            placevill.setValue("");
        }
    }

    function onMouseOut() {
        var id = mini.get("znsfid").getValue();
        if (id != "") {
            if (id.length == 18 && onIDCardsValidation(id)) {
                var age = id.substring(6, 10) + "-" + id.substring(10, 12) + "-" + id.substring(12, 14);
                mini.get("age").setValue(age);
                var num = id[16];
                if(num%2 ==0){
                    mini.get("Sex").setValue("2");
                } else {
                    mini.get("Sex").setValue("1");
                }
            } else if (id.length == 15 && onIDCardsValidation(idNum.getValue())) {
                var num = id[14];
                if(num%2 ==0){
                    mini.get("Sex").setValue("2");
                } else {
                    mini.get("Sex").setValue("1");
                }
            } else {
                mini.alert("请输入正确的身份证号码");
            }
        }
    }

    window.onload = function () {
        var localCode = '${localCode!''}';
        if(localCode == '140000') {
            var placepro='${placepro!''}';
            var placecity='${placecity!''}';
            var placecou='${placecou!''}';
            var placevill='${placevill!''}';
            var placenum='${placenum!''}';
            var name='${name!''}';
            var sex='${sex!''}';
            var znsfid='${znsfId!''}';
            var age='${age!''}';
            var jianhuren='${jianhuren!''}';
            var kunnan='${kunnan!''}';
            var shixue='${shixue!''}';
            var liulang='${liulang!''}';
            var fanzui='${fanzui!''}';
            var nativepro='${nativepro!''}';
            var nativecity='${nativecity!''}';
            var nativecou='${nativecou!''}';
            var nativevill='${nativevill!''}';
            var nativenum='${nativenum!''}';
            var idType ='${idType!''}';
            if(idType == "true"){
                document.getElementById("idType1").style.display = "inline-block";
            }
            if(placepro == "true" || placecity == "true" || placecou == "true" || placevill =="true"){
                document.getElementById("placevill1").style.display = "inline-block";
            }
            if(placenum == "true"){
                document.getElementById("placenum1").style.display = "inline-block";
            }
            if(name == "true"){
                document.getElementById("name1").style.display = "inline-block";
            }
            if(sex == "true"){
                document.getElementById("sex1").style.display = "inline-block";
            }
            if(znsfid == "true"){
                document.getElementById("znsfid1").style.display = "inline-block";
            }
            if(age == "true"){
                document.getElementById("age1").style.display = "inline-block";
            }
            if(jianhuren == "true"){
                document.getElementById("jianhuren1").style.display = "inline-block";
            }if(kunnan == "true"){
                document.getElementById("kunnan1").style.display = "inline-block";
            }
            if(shixue == "true"){
                document.getElementById("shixue1").style.display = "inline-block";
            }
            if(liulang == "true"){
                document.getElementById("liulang1").style.display = "inline-block";
            }
            if(fanzui == "true"){
                document.getElementById("fanzui1").style.display = "inline-block";
            }
            if(nativepro == "true" || nativecity == "true" || nativecou == "true" || nativevill =="true"){
                document.getElementById("nativevill1").style.display = "inline-block";
            }
            if(nativenum == "true"){
                document.getElementById("nativenum1").style.display = "inline-block";
            }
        }
    }
</script>
</body>
</html>